home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.flash.net!usenet
- From: Quadra-Tech <quadra@flash.net>
- Newsgroups: comp.lang.c
- Subject: Re: Converting Strings to Upper Case
- Date: Tue, 26 Mar 1996 11:24:41 -0600
- Organization: FlashNet
- Message-ID: <31582859.3922@flash.net>
- References: <4ifra6$52i@scipio.cyberstore.ca> <827087843snz@genesis.demon.co.uk>
- NNTP-Posting-Host: p-83.flash.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
-
- Lawrence Kirby wrote:
- >
- > In article <4ifra6$52i@scipio.cyberstore.ca> ejw@news.cyberstore.ca "
- > " writes:
- >
- > >Hi,
- > >
- > >I need to write a function to convert a string containg upper or lower case
- > >characters to the opposite case. Something like:
- > >
- > > void libConvertUpperCase(char *str); and
- > > void libConvertLowerCase(char *str);
- > >
- > >and the string would be modified. I just can't seem to wrap my head around
- > >the best way that I know is better than writing a for loop to check each
- > >element in the array?
- >
- > That sentence doesn't parse. The best way that I know is to write a for loop
- > and check each character in the string - any method will ultimately boil
- > down to this. If you think you know of a better method perhaps you
- > could explain?
- >
- > --
- > -----------------------------------------
- > Lawrence Kirby | fred@genesis.demon.co.uk
- > Wilts, England | 70734.126@compuserve.com
- > -----------------------------------------
-
-
- Try this function and see if it works for you. Good luck.
-
-
- char string[] = "This is a String";
-
- void char fnReverse(char letter)
-
- int ndx;
-
- {
- for (n = 0; string[n] != 0; n++)
- {
- if (isupper(string[n]) == 0)
- {
- string[n] = tolower(string[n]);
- continue;
- }
-
- string[n] = toupper(string[n]);
- }
-
- --
- \|/ ____ \|/ _ _ ` _ '
- //// @~/ ,. \~@ o' \,=./ `o - (_) -
- (o -) /_( \__/ )_\ (o o) ' `
- +-----------ooO--(_)--Ooo-----\__U_/----ooO--(_)--Ooo------------------+
- ^ ^
- ^ QUADRA-TECH BOYS ^
- ^ DATA PROCESSING GURU ^
- ^ DIRECT MAIL SOFTWARE BEST OF THE BEST ^
- ^ ^
- +----------------------------------------------------------------------+
-